#{extends 'wxcpMain.html' /}
<div class="page-group">
    <div class="page page-current" id="work-order-detail">
        <header class="bar bar-nav">
            <a href="javascript:history.go(-1);" class="icon icon-left pull-left"></a>
            <h1 class="title">报修详情</h1>
        </header>
        <section class="payDetail content scroll_y">
            <div class="card0 m6">
                <div class="card-content">
                    <ul>
                        <li>
                            <h3 id="work-detail-name">${issue?.issueName}</h3>
                        </li>
                        <li>
                            <h3>报修人：${issue?.user?.realName}</h3>
                        </li>
                        <li>
                            <h3>联系电话：${issue?.phone}</h3>
                        </li>
                        <li>
                            <h3 id="work-detial-time">上门时间：${issue?.visitTimeBegin}~${issue?.visitTimeEnd}</h3>
                        </li>
                        <li>
                            <h3>描述说明：${issue?.remark}</h3>
                        </li>
                    </ul>
                </div>
                <div class="card-footer">
                    <div class="content-block uploadPic">
                        <ul>
                        #{list images , as :'image'}
                            <li class="img">
                                <img src="${image?.ossPath}"/>
                            </li>
                        #{/list}
                        </ul>
                    </div>
                </div>
            </div>
            <div class="list-block">
                <div class="content-block-title">预估金额</div>
                <ul>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">金额</div>
                                <div class="item-input">
                                    <input type="text" placeholder="请输入维修预估金额..." id="issue_salary">
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="content-block">
            #{if issue?.issueStatus.toString() == 'ACCEPT' || issue?.issueStatus.toString() == 'ACCEPT'}
                <input type="button" name="button" class="button button-fill button-big button-orange" id="acceptIssue" value="提交">
            #{/if}
            #{else }
                <input type="button" name="button" class="button button-fill button-big button-orange disabled"  value="已估价">
            #{/else}
            </div>
            <script type="text/javascript">
                var issueId = '${issue?.id}';
                var bind_name = 'input';
                if (navigator.userAgent.indexOf("MSIE") != -1){
                    bind_name = 'propertychange';
                }
                var getCurrectNumber = function(input_num){
                    var decimal = "";
                    var integer;
                    if (input_num.split(".").length >= 2) {
                        decimal = "."+input_num.split(".")[1];
                        integer = input_num.split(".")[0];
                    }else {
                        integer = input_num;
                    }
                    var num = Number(integer);
                    input_num = num.toString() + decimal;
                    num =  Number(input_num);
//                  num = Math.floor(num*100)/100;
                    if(num>100000000.00){
                        input_num = "0";
                        alert("数字过大，请重新输入!");
                    }
                    if (input_num.split(".").length == 2 && input_num.split(".")[1].length > 2){
                        num = num.toFixed(2);
                        input_num = num.toString();
                    }
                    return input_num;
                }

                $("#issue_salary").on(bind_name,function(event){
                    var input_num = $(this).val().replace(/[^0-9.]/g,'');
                    input_num = getCurrectNumber(input_num);
                    $(this).val(input_num);
                }).bind("paste",function(){  //CTR+V事件处理
                    var input_num = $(this).val().replace(/[^0-9.]/g,'');
                    input_num = getCurrectNumber(input_num);
                    $(this).val(input_num);
                }).css("ime-mode", "disabled"); //CSS设置输入法不可用

                $('#acceptIssue').on('click',function () {
                    var salary = $('#issue_salary').val();
                    if(salary == null || salary == undefined || salary == '') {
                        $.toast("请输入您预估的金额!");
                    }
                    $.getJSON('/wxcp/engineerVisitForIssue',{issueId:issueId,salary:salary}, function(data){
                        if(data.success) {
                            $.alert(data.msg);
                            window.location.href = '/wxcp/issueListEngineer';
                        }else {
                            $.alert(data.msg);
                        }
                    });
                })
            </script>
        </section>

    #{include 'wxcp/footer.html'/}

    </div>
</div>
